<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets">
	<script type="text/javascript">

		var childW = null;

			function launchChildW() {
				
			  var url = "${request.contextPath}/webcam.jsp";
			   
			  wopts  = 'width=300,height=300,resizable=1,alwaysRaised=1,scrollbars=1,modal=yes';
	
			  if (window.showModalDialog) {
					window.showModalDialog(url,self,wopts);
				} else {
					window.open(url,'Popup',wopts);
				}
			}
			
	function setImage(im) {
		
		var ee = document.getElementById('snap');
		while (ee.hasChildNodes()) {
	        ee.removeChild(ee.firstChild);
	    }			   
        var element1 = document.createElement("img");
        element1.src = "${request.contextPath}/" + im;
        element1.id = "imgctrl";
        element1.alt = "No Protograph";
        element1.width= 320;
        element1.height=240; 
        ee.appendChild(element1);	            
	}

	function showLarge(ev,tar,url) {
		var ee = document.getElementById('imageEnlarged');
		ee.style.left = (ev.pageX + 50)+"px";
		ee.style.top = (ev.pageY - 120 )+"px";
        ee.src=url; 
		ee.style.visibility="visible";				
	}
	
	function hideLarge() {
		var ee = document.getElementById('imageEnlarged');
        ee.src="";
		ee.style.visibility="hidden";
	}

	var superdata = "";

	function loadCam() {

		jQuery("#webcam").webcam({
		
			width: 320,
			height: 240,
			mode: "callback",
			swffile: "${request.contextPath}/webcam/jscam.swf",
		
			onTick: function(remain) {						
			},
		
			onSave: function(data) {
				superdata+=data + "|";
			},
		
			onCapture: function () {

				superdata="";
				webcam.save();
		
				jQuery.post(  "${request.contextPath}/bss/images/click", { data1: superdata},
						  function(dta) {				  					   
				            clicked(dta);				   
						   }, "html");
			},
		
			debug: function (type, string) {		
			},
		
			onLoad: function () {
			}
		});
	}

	function clicked(im) {
		try {
			setImage(im);
		}catch(e) {				
			alert(e);				
		}
	}

	</script>
</ui:composition>